--BANG NHANVIEN
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME ='NHANVIEN')
BEGIN
	DROP TABLE NHANVIEN
END
GO
CREATE TABLE NHANVIEN
(
	MANV	varchar(15),
	TEN		nvarchar(20),
	DCHI	nvarchar(50),
	DTHOAI	varchar(15),
	LUONG	float,
	LOAINV	int

	PRIMARY KEY (MANV)
)
SELECT * FROM NHANVIEN

--BANG KHACHHANG
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME ='KHACHHANG')
BEGIN
	DROP TABLE KHACHHANG
END
GO
CREATE TABLE KHACHHANG
(
	MAKH	varchar(15),
	TEN		nvarchar(10),
	DCHI	varchar(30),
	DTHOAI	varchar(15)

	PRIMARY KEY (MAKH)
)
SELECT * FROM KHACHHANG

--BANG KHANANG
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME ='KHANANG')
BEGIN
	DROP TABLE KHANANG
END
GO
create table KHANANG
(
	MANV	varchar(15),
	MALOAI	varchar(15)

	PRIMARY KEY (MANV,MALOAI)
)
	SELECT * FROM KHANANG

--BANG LOAI MAY BAY
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME ='LOAIMB')
BEGIN
	DROP TABLE LOAIMB
END
GO
CREATE TABLE LOAIMB
(
	HANGSX	varchar(10),
	MALOAI	varchar(15)

	PRIMARY KEY (MALOAI)
)
	SELECT * FROM LOAIMB

--BANG DAT CHO
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME ='DATCHO')
BEGIN
	DROP TABLE DATCHO
END
GO
CREATE TABLE DATCHO
(
	MAKH	varchar(15),
	NGAYDI	datetime,
	MACB	varchar(15)

	PRIMARY KEY (MAKH,NGAYDI,MACB)
)
select * from DATCHO

--BANG PHANCONG
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME ='PHANCONG')
BEGIN
	DROP TABLE PHANCONG
END
GO
CREATE TABLE PHANCONG
(
	MANV	varchar(15),
	NGAYDI	datetime,
	MACB	varchar(15)

	PRIMARY KEY(MANV,NGAYDI,MACB)
)
SELECT * FROM PHANCONG

--BANG LICH BAY
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME ='LICHBAY')
BEGIN
	DROP TABLE LICHBAY
END
GO
CREATE TABLE LICHBAY
(
	NGAYDI	datetime,
	MACB	varchar(15),
	SOHIEU	int,
	MALOAI	varchar(15)

	PRIMARY KEY (NGAYDI,MACB)
)
SELECT * FROM LICHBAY

--BANG CHUYEN BAY
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME ='CHUYENBAY')
BEGIN
	DROP TABLE CHUYENBAY
END
GO
CREATE TABLE CHUYENBAY
(
	MACB	varchar(15),
	SBDI	varchar(10),
	SBDEN	varchar(10),
	GIODI	datetime,
	GIODEN	datetime

	PRIMARY KEY (MACB)
)	
SELECT * FROM CHUYENBAY

--BANG MAYBAY
IF EXISTS (SELECT * FROM DBO.SYSOBJECTS WHERE NAME ='MAYBAY')
BEGIN
	DROP TABLE MAYBAY
END
GO
CREATE TABLE MAYBAY
(
	SOHIEU	int,
	MALOAI	varchar(15)

	PRIMARY KEY (SOHIEU,MALOAI)
)
SELECT * FROM MAYBAY
